<?php
// +----------------------------------------------------------------------
// | 链乡 [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017 http://www.twothink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: codeshuhao
// +----------------------------------------------------------------------

namespace app\admin\controller;


use app\admin\service\BuildService;

class BuildController extends BaseController
{
    private $build = null;

    public function __construct()
    {
        parent::__construct();

        $this->build = new BuildService();
    }

    /**
     * @action 脚手架
     * @return mixed
     */
    public function helper()
    {
        //判断请求类型
        $this->isPost();

        $data = $this->build->getView();

        $this->assign('data',$data);

        return $this->fetch();
    }

    public function helperpost()
    {
        $data = input('post.');

        //自动代码生成
        $data = $this->build->helper($data);

        if ( $data === false )
        {
            dump($this->build->getError());exit;
        }

        return $data;
    }

    /**
     * @action 新模块
     */
    public function module()
    {
        $this->isPost();

        return $this->fetch();
    }

    public function modulepost()
    {
        $request = input('post.');

        if( $this->build->module($request) === false )
        {
            echo $this->build->getError();
        }

        echo 1;
    }
}